Leading Zero
   HOME

TheInfoList



OR:

A leading zero is any 0 digit that comes before the first nonzero digit in a number string in positional notation.. For example,
James Bond The ''James Bond'' series focuses on a fictional British Secret Service agent created in 1953 by writer Ian Fleming, who featured him in twelve novels and two short-story collections. Since Fleming's death in 1964, eight other authors have ...
's famous identifier, 007, has two leading zeros. Any zeroes appearing to the left of the first non-zero digit (of any integer or decimal) do not affect its value, and can be omitted (or replaced with blanks) with no loss of information. Therefore, the usual
decimal The decimal numeral system (also called the base-ten positional numeral system and denary or decanary) is the standard system for denoting integer and non-integer numbers. It is the extension to non-integer numbers of the Hindu–Arabic numeral ...
notation of
integer An integer is the number zero (), a positive natural number (, , , etc.) or a negative integer with a minus sign (−1, −2, −3, etc.). The negative numbers are the additive inverses of the corresponding positive numbers. In the language ...
s does not use leading zeros except for the zero itself, which would be denoted as an
empty string In formal language theory, the empty string, or empty word, is the unique string of length zero. Formal theory Formally, a string is a finite, ordered sequence of characters such as letters, digits or spaces. The empty string is the special cas ...
otherwise. However, in
decimal fraction The decimal numeral system (also called the base-ten positional numeral system and denary or decanary) is the standard system for denoting integer and non-integer numbers. It is the extension to non-integer numbers of the Hindu–Arabic num ...
s strictly between −1 and 1, the leading zeros digits between the
decimal point A decimal separator is a symbol used to separate the integer part from the fractional part of a number written in decimal form (e.g., "." in 12.45). Different countries officially designate different symbols for use as the separator. The choi ...
and the first nonzero digit are necessary for conveying the magnitude of a number and cannot be omitted, while
trailing zero In mathematics, trailing zeros are a sequence of 0 in the decimal representation (or more generally, in any positional representation) of a number, after which no other digits follow. Trailing zeros to the right of a decimal point, as in 12.340 ...
s – zeros occurring after the decimal point and after the last nonzero digit – can be omitted without changing the meaning.


Occurrence

Often, leading zeros are found on non-electronic
digital display A display device is an output device for presentation of information in visual or tactile form (the latter used for example in tactile electronic displays for blind people). When the input information that is supplied has an electrical signal t ...
s or on such electronic ones as
seven-segment display A seven-segment display is a form of electronic display device for displaying decimal numerals that is an alternative to the more complex dot matrix displays. Seven-segment displays are widely used in digital clocks, electronic meters, basic ...
s, that contain fixed sets of digits. These devices include manual counters,
stopwatch A stopwatch is a timepiece designed to measure the amount of time that elapses between its activation and deactivation. A large digital version of a stopwatch designed for viewing at a distance, as in a sports stadium, is called a stop clock. ...
es,.
odometer An odometer or odograph is an instrument used for measuring the distance traveled by a vehicle, such as a bicycle or car. The device may be electronic, mechanical, or a combination of the two (electromechanical). The noun derives from ancient Gr ...
s, and
digital clock A digital clock is a type of clock that displays the time digitally (i.e. in numerals or other symbols), as opposed to an analogue clock. Digital clocks are often associated with electronic drives, but the "digital" description refers only t ...
s. Leading zeros are also generated by many older computer programs when creating values to assign to new records, accounts and other files, and as such are likely to be used by utility billing systems, human resources information systems and government databases. Many
digital camera A digital camera is a camera that captures photographs in digital memory. Most cameras produced today are digital, largely replacing those that capture images on photographic film. Digital cameras are now widely incorporated into mobile device ...
s and other electronic media recording devices use leading zeros when creating and saving new files to make names of the equal length. Leading zeros are also present whenever the number of digits is fixed by the technical system (such as in a
memory register A processor register is a quickly accessible location available to a computer's processor. Registers usually consist of a small amount of fast storage, although some registers have specific hardware functions, and may be read-only or write-only. ...
), but the stored value is not large enough to result in a non-zero
most significant digit Significant figures (also known as the significant digits, ''precision'' or ''resolution'') of a number in positional notation are digits in the number that are reliable and necessary to indicate the quantity of something. If a number expres ...
. The
count leading zeros In computer software and hardware, find first set (ffs) or find first one is a bit operation that, given an unsigned machine word, designates the index or position of the least significant bit set to one in the word counting from the least signifi ...
operation efficiently determines the number of leading zero
bit The bit is the most basic unit of information in computing and digital communications. The name is a portmanteau of binary digit. The bit represents a logical state with one of two possible values. These values are most commonly represente ...
s in a
machine word In computing, a word is the natural unit of data used by a particular processor design. A word is a fixed-sized datum handled as a unit by the instruction set or the hardware of the processor. The number of bits or digits in a word (the ''word s ...
. A leading zero appears in
roulette Roulette is a casino game named after the French word meaning ''little wheel'' which was likely developed from the Italian game Biribi''.'' In the game, a player may choose to place a bet on a single number, various groupings of numbers, the ...
in the United States, where "00" is distinct from "0" (a wager on "0" will not win if the ball lands in "00", and vice versa). Sports where competitors are numbered follow this as well; a
stock car Stock car racing is a form of automobile racing run on oval tracks and road courses measuring approximately . It originally used production-model cars, hence the name "stock car", but is now run using cars specifically built for racing. It ori ...
numbered "07" would be considered distinct from one numbered "7".
Benito Santiago Benito Santiago Rivera (born March 9, 1965), is a Puerto Rican former professional baseball player. He played as a catcher in Major League Baseball from 1986 to 2005, most prominently as a member of the San Diego Padres, with whom he was a fou ...
, a
Major League Baseball Major League Baseball (MLB) is a professional baseball organization and the oldest major professional sports league in the world. MLB is composed of 30 total teams, divided equally between the National League (NL) and the American League (AL), ...
catcher who wore the number 09 for several years, is the only major professional sports league player to use a
jersey number In team sports, the number, often referred to as the uniform number, squad number, jersey number, shirt number, sweater number, or similar (with such naming differences varying by sport and region) is the number worn on a player's uniform, to ...
with a leading zero, not counting several who have worn the number 00 (he wore the extra zero to avoid complications with his catcher's pads, allowing the back strap to run between the numbers instead of over a single digit 9).
Dennis Rodman Dennis Keith Rodman (born May 13, 1961) is an American former professional basketball player. Known for his fierce defensive and rebounding abilities, his biography on the official NBA website states that he is "arguably the best rebounding ...
had requested the number 01 when he joined the
Chicago Bulls The Chicago Bulls are an American professional basketball team based in Chicago. The Bulls compete in the National Basketball Association (NBA) as a member of the league's Eastern Conference Central Division. The team was founded on January 1 ...
(as his usual number 10 had already been retired), but the
National Basketball Association The National Basketball Association (NBA) is a professional basketball league in North America. The league is composed of 30 teams (29 in the United States and 1 in Canada) and is one of the major professional sports leagues in the United S ...
forbade it, and Rodman instead wore 91. In most countries other than the United States, numbers between 0 and 1, expressed as a decimal, include a zero before the decimal point (eg 0.64 or in many countries 0,64) while in the United States this zero is often omitted (.64).


Advantages


Collation

Leading zeros are used to make ascending order of numbers correspond with
alphabetical order Alphabetical order is a system whereby character strings are placed in order based on the position of the characters in the conventional ordering of an alphabet. It is one of the methods of collation. In mathematics, a lexicographical order is t ...
: e.g., 11 comes alphabetically before 2, but after 02. (See, e.g.,
ISO 8601 ISO 8601 is an international standard covering the worldwide exchange and communication of date and time-related data. It is maintained by the Geneva-based International Organization for Standardization (ISO) and was first published in 1988, w ...
.) This does not work with
negative number In mathematics, a negative number represents an opposite. In the real number system, a negative number is a number that is less than zero. Negative numbers are often used to represent the magnitude of a loss or deficiency. A debt that is owed m ...
s, though, whether leading zeros are used or not: −23 comes alphabetically after −01, −1, and −22, although it is less than all of them.


Error prevention

Leading zeros in a sentence also make it less likely that a careless reader will overlook the decimal point. For example, in modern
pharmacy Pharmacy is the science and practice of discovering, producing, preparing, dispensing, reviewing and monitoring medications, aiming to ensure the safe, effective, and affordable use of medicines. It is a miscellaneous science as it links heal ...
there is a widely followed convention that leading zeros before a decimal must not be omitted from any dose or dosage value in drug prescribing (e.g. ''0.2 mg'' must be used, not ''.2 mg'') . Likewise, just as leading zeros are mandatory,
trailing zero In mathematics, trailing zeros are a sequence of 0 in the decimal representation (or more generally, in any positional representation) of a number, after which no other digits follow. Trailing zeros to the right of a decimal point, as in 12.340 ...
s are forbidden (e.g. ''2 mg'' must be used, not ''2.0 mg''). In both cases, the reason is the same: to prevent misreading and the resultant misdose by one or several
orders of magnitude An order of magnitude is an approximation of the logarithm of a value relative to some contextually understood reference value, usually 10, interpreted as the base of the logarithm and the representative of values of magnitude one. Logarithmic dis ...
.


Fraud prevention

Leading zeros can also be used to prevent fraud by filling in character positions that might normally be empty. For example, adding leading zeros to the amount of a
check Check or cheque, may refer to: Places * Check, Virginia Arts, entertainment, and media * ''Check'' (film), a 2021 Indian Telugu-language film * ''The Checks'' (episode), a 1996 TV episode of ''Seinfeld'' Games and sports * Check (chess), a thr ...
(or similar financial document) makes it more difficult for fraudsters to alter the amount of the check before presenting it for payment.


Zero as a prefix

A prefix 0 is used in C to specify string representations of
octal The octal numeral system, or oct for short, is the radix, base-8 number system, and uses the Numerical digit, digits 0 to 7. This is to say that 10octal represents eight and 100octal represents sixty-four. However, English, like most languages, ...
numbers, as required by the
ANSI C ANSI C, ISO C, and Standard C are successive standards for the C programming language published by the American National Standards Institute (ANSI) and ISO/IEC JTC 1/SC 22/WG 14 of the International Organization for Standardization (ISO) and th ...
standard for the "strtol" function (the string to long integer converter) in the "stdlib.h" library. Many other programming languages, such as
Python Python may refer to: Snakes * Pythonidae, a family of nonvenomous snakes found in Africa, Asia, and Australia ** ''Python'' (genus), a genus of Pythonidae found in Africa and Asia * Python (mythology), a mythical serpent Computing * Python (pro ...
,
Perl Perl is a family of two high-level, general-purpose, interpreted, dynamic programming languages. "Perl" refers to Perl 5, but from 2000 to 2019 it also referred to its redesigned "sister language", Perl 6, before the latter's name was offici ...
,
Ruby A ruby is a pinkish red to blood-red colored gemstone, a variety of the mineral corundum ( aluminium oxide). Ruby is one of the most popular traditional jewelry gems and is very durable. Other varieties of gem-quality corundum are called sa ...
,
PHP PHP is a general-purpose scripting language geared toward web development. It was originally created by Danish-Canadian programmer Rasmus Lerdorf in 1993 and released in 1995. The PHP reference implementation is now produced by The PHP Group. ...
, and the Unix shell
bash Bash or BASH may refer to: Arts and entertainment * ''Bash!'' (Rockapella album), 1992 * ''Bash!'' (Dave Bailey album), 1961 * '' Bash: Latter-Day Plays'', a dramatic triptych * ''BASH!'' (role-playing game), a 2005 superhero game * "Bash" ('' ...
also follow this specification for converting strings to numbers. As an example, "0020" does not represent 2010 (2×101 + 0×100), but rather 208 = 1610 (2×81 + 0×80 = 1×101 + 6×100). Decimal numbers written with leading zeros will be interpreted as octal by languages that follow this convention and will generate errors (not just unexpected results) if they contain "8" or "9", since these digits do not exist in octal. This behavior can be quite a nuisance when working with sequences of strings with embedded, zero-padded
decimal The decimal numeral system (also called the base-ten positional numeral system and denary or decanary) is the standard system for denoting integer and non-integer numbers. It is the extension to non-integer numbers of the Hindu–Arabic numeral ...
numbers (typically file names) to facilitate alphabetical sorting (see above) or when validating inputs from users who would not know that adding a leading zero triggers this base conversion.


See also

*
Trailing zero In mathematics, trailing zeros are a sequence of 0 in the decimal representation (or more generally, in any positional representation) of a number, after which no other digits follow. Trailing zeros to the right of a decimal point, as in 12.340 ...
* 00 (disambiguation) * Leading digit


References

{{DEFAULTSORT:Leading Zero Computer data Digital electronics Numeral systems 0 (number)